<?php namespace App\Http\Controllers\Front;


use Illuminate\Http\Request;
use App\Models\Employ;
use App\Models\Teaches;
use App\Models\TeachesCompany;
use App\Models\BbsQuestion;
use App\Models\TeachesContent;
class AccordController extends MasterController 
{
	
    protected $report_type = array();
    protected $report_type_2 = array();
    
    public function __construct()
    {
        $this->report_type = array('1'=>'个人攻击','企业诽谤');
        $this->report_type_2 = array(1=>'广告类',2=>'政治有害类',3=>'暴恐类',4=>'淫秽色情类',5=>'头像、签名档',6=>'赌博类',7=>'私服外挂类',8=>'诈骗类',9=>'其他有害类');
    }
    
	public function index(){
		return view('front.accord');
	}
	
	/**
	 * 用户举报 
	 */
	public function report(Request $req)
	{	    
        $app = $req->input('app','');
        $app_id = $req->input('app_id',0);
        switch ($app)
        {
            case 'employ':
                $result = Employ::with('user')->find($app_id);break;
            case 'teaches':
                $result = Teaches::with('user')->find($app_id);break;
            case 'teaches_company':
                $result = TeachesCompany::with('user')->find($app_id);
                if($result->teaches_type == 0)
                {
                    $description = unserialize($result->description);
                    $result->description = $description['name'];
                }
                break;
            case 'teaches_content':
                $result = TeachesContent::with('user')->find($app_id);
                if($result->teaches_type == 0)
                {
                    $description = unserialize($result->description);
                    $result->description = $description['name'];
                }
                break;
            case 'bbs_question':
                $result = BbsQuestion::with('user')->find($app_id);break;
            default:
                $result = Employ::with('user')->find($app_id);break;
        }
        $url = $req->input('app_url','');
        $report_type = $req->input('report_type',1);
        $view = view('front.report.create')->with('reptypes',$this->report_type_2)
            ->with('app_id',$app_id)
            ->with('result',$result)
            ->with('report_type',$report_type)
            ->with('url',$url)
            ->with('app',$app);

        if($app == 'employ') {
            $view->with('nav',1);
        }
        if($app == 'teaches' || $app == 'teaches_company' || $app == 'teaches_content') {
            $view->with('nav',2);
        }
        if($app == 'bbs_question') {
            $view->with('nav',4);
        }
        return $view;
//        return view('front.report.create')->with('nav',1)->with('reptypes',$this->report_type_2)
//               ->with('app_id',$app_id)
//               ->with('result',$result)
//               ->with('report_type',$report_type)
//               ->with('url',$url)
//               ->with('app',$app);
	}
}